<? /* license

BilugCMS (http://www.bilug.it) - Content Management System for dynamic web sites
Copyright (C) 2005-2008  Federico Villa and Alessio Loro Piana

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

For reference, contact bilugcms@vilnet.it


license */ ?>
<link type="text/css" href="../utility/smoothness/jquery-ui-1.7.1.custom.css" rel="stylesheet" />
<script type="text/javascript" src="../js/jquery.js"></script>
<script type="text/javascript" src="../js/ui.core.js"></script>
<script type="text/javascript" src="../js/ui.sortable.js"></script>
<script type="text/javascript" src="../js/jquery.cluetip.js" ></script>

<style type="text/css">
	/*Liste brevi*/
	/*Comuni*/
	#sortable1, #sortable2, #sortable3,#sortable , #sortable5 { list-style-type: none; margin: 0; padding: 0; float: left; margin-right: 10px; width: 200px; }
	#sortable1 li, #sortable2 li, #sortable3 li,#sortable li, #sortable5 li { 
	margin: 5px 0; padding: 0; font-size: 1.2em; width: 200px; }
	#sortable1 li span, #sortable2 li span, #sortable3 li span ,#sortable5 li span{float: right;}
	/*Utenti*/
	#sortable11, #sortable12, #sortable13 { list-style-type: none; margin: 0; padding: 0; float: left; margin-right: 10px; width: 200px; }
	#sortable11 li, #sortable12 li, #sortable13 li { 
	margin: 5px 0; padding: 0; font-size: 1.2em; width: 200px; }
	#sortable11 li span, #sortable12 li span, #sortable13 li span {float: right;}
	/*Admin*/	
	/*Liste lunghe*/
	/*Comuni*/
	#sortable0, #sortable4 { list-style-type: none; margin: 0; padding: 0; margin-right: 10px; }
	#sortable0 li, #sortable4 li { 
	margin: 5px 0; padding: 0; font-size: 1.2em; width: 665px; }
	#sortable0 li span, #sortable4 li span {float: right;}
	/*Utenti*/
	#sortable10, #sortable14 { list-style-type: none; margin: 0; padding: 0; margin-right: 10px; }
	#sortable10 li, #sortable14 li { 
	margin: 5px 0; padding: 0; font-size: 1.2em; width: 665px; }
	#sortable10 li span, #sortable14 li span {float: right;}
	/*Admin*/
	#sortable20, #sortable21, #sortable22 { 
	list-style-type: none; margin: 0; padding: 0; margin-right: 10px; }
	#sortable20 li, #sortable21 li , #sortable22 li{ 
	margin: 5px 0; padding: 0; font-size: 1.2em; width: 665px; }
	#sortable20 li span, #sortable21 li span, #sortable22 li span {float: right;}
	/*Classe Area supporto*/
	.utility {float: right; width: 210px;}
	.moduli {float: left; width: 675px; }
	</style>
	<script type="text/javascript">
	$(function() {
		$("#sortable, #sortable0, #sortable1, #sortable2, #sortable3, #sortable4, #sortable5, #sortable10, #sortable11, #sortable12, #sortable13, #sortable14, #sortable20, #sortable21, #sortable22 ").sortable({
			connectWith: '.connectedSortable',
			placeholder: 'ui-state-highlight',
			cursor: 'move',			
			forcePlaceholderSize: true,
			start: function(event,ui) {
				var $child = $(this).children();
				$child.css('width','200px');				
			}		
		}).disableSelection();
		$("#sortable5").bind('sortupdate', function(event,ui) {
				var result = $("#sortable5").sortable('toArray');
  				$.post("insert_moduli_query_new.php",{'id[]':result,'lato':'1','area':1},
  			function(data){if (data !='') alert(data);}, "text");
  				$("#sortable5 li").removeClass('ui-state-default').addClass('ui-state-error');
		});
		$("#sortable0").bind('sortupdate', function(event,ui) {
				var result = $("#sortable0").sortable('toArray');
  				$.post("insert_moduli_query_new.php",{'id[]':result,'lato':'a','area':'t'},
  			function(data){if (data !='') alert(data);}, "text");
  				$("#sortable0 li").removeClass('ui-state-error').addClass('ui-state-default');
		});
		$("#sortable1").bind('sortupdate', function(event,ui) {
				var result = $("#sortable1").sortable('toArray');
  				$.post("insert_moduli_query_new.php",{'id[]':result,'lato':'s','area':'t'},
  			function(data){if (data !='') alert(data);}, "text");
  				$("#sortable1 li").removeClass('ui-state-error').addClass('ui-state-default');
		});
		$("#sortable2").bind('sortupdate', function(event,ui) {
				var result = $("#sortable2").sortable('toArray');
  				$.post("insert_moduli_query_new.php",{'id[]':result,'lato':'c','area':'t'},
  			function(data){if (data !='') alert(data);}, "text");
  				$("#sortable2 li").removeClass('ui-state-error').addClass('ui-state-default');
		});
		$("#sortable3").bind('sortupdate', function(event,ui) {
				var result = $("#sortable3").sortable('toArray');
  				$.post("insert_moduli_query_new.php",{'id[]':result,'lato':'d','area':'t'},
  			function(data){if (data !='') alert(data);}, "text");
  				$("#sortable3 li").removeClass('ui-state-error').addClass('ui-state-default');			
		});
		$("#sortable4").bind('sortupdate', function(event,ui) {
				var result = $("#sortable4").sortable('toArray');
  				$.post("insert_moduli_query_new.php",{'id[]':result,'lato':'b','area':'t'},
  			function(data){if (data !='') alert(data);}, "text");
  				$("#sortable4 li").removeClass('ui-state-error').addClass('ui-state-default');			
		});	
		$("#sortable10").bind('sortupdate', function(event,ui) {
				var result = $("#sortable10").sortable('toArray');
  				$.post("insert_moduli_query_new.php",{'id[]':result,'lato':'a','area':'u'},
  			function(data){if (data !='') alert(data);}, "text");
  				$("#sortable10 li").removeClass('ui-state-error').addClass('ui-state-default');
		});
		$("#sortable11").bind('sortupdate', function(event,ui) {
				var result = $("#sortable11").sortable('toArray');
  				$.post("insert_moduli_query_new.php",{'id[]':result,'lato':'s','area':'u'},
  			function(data){if (data !='') alert(data);}, "text");
  				$("#sortable11 li").removeClass('ui-state-error').addClass('ui-state-default');
		});
		$("#sortable12").bind('sortupdate', function(event,ui) {
				var result = $("#sortable12").sortable('toArray');
  				$.post("insert_moduli_query_new.php",{'id[]':result,'lato':'c','area':'u'},
  			function(data){if (data !='') alert(data);}, "text");
  				$("#sortable12 li").removeClass('ui-state-error').addClass('ui-state-default');
		});
		$("#sortable13").bind('sortupdate', function(event,ui) {
				var result = $("#sortable13").sortable('toArray');
  				$.post("insert_moduli_query_new.php",{'id[]':result,'lato':'d','area':'u'},
  			function(data){if (data !='') alert(data);}, "text");
  				$("#sortable13 li").removeClass('ui-state-error').addClass('ui-state-default');			
		});
		$("#sortable14").bind('sortupdate', function(event,ui) {
				var result = $("#sortable14").sortable('toArray');
  				$.post("insert_moduli_query_new.php",{'id[]':result,'lato':'b','area':'u'},
  			function(data){if (data !='') alert(data);}, "text");
  				$("#sortable14 li").removeClass('ui-state-error').addClass('ui-state-default');			
		});
		$("#sortable20").bind('sortupdate', function(event,ui) {
				var result = $("#sortable20").sortable('toArray');
  				$.post("insert_moduli_query_new.php",{'id[]':result,'lato':'a','area':'a'},
  			function(data){if (data !='') alert(data);}, "text");
  				$("#sortable20 li").removeClass('ui-state-error').addClass('ui-state-default');
		});
		$("#sortable21").bind('sortupdate', function(event,ui) {
				var result = $("#sortable21").sortable('toArray');
  				$.post("insert_moduli_query_new.php",{'id[]':result,'lato':'c','area':'a'},
  			function(data){if (data !='') alert(data);}, "text");
  				$("#sortable21 li").removeClass('ui-state-error').addClass('ui-state-default');
		});
		$("#sortable22").bind('sortupdate', function(event,ui) {
				var result = $("#sortable22").sortable('toArray');
  				$.post("insert_moduli_query_new.php",{'id[]':result,'lato':'b','area':'a'},
  			function(data){if (data !='') alert(data);}, "text");
  				$("#sortable22 li").removeClass('ui-state-error').addClass('ui-state-default');
		});
	$("#cancella").click(function(){
  			var result = $("#sortable").sortable('toArray');
  			$.post("insert_moduli_query_new.php",{'id[]':result,'lato':'0','area':0},
  			function(data){if (data !='') alert(data);$("#sortable li").remove();}, "text");});
  			$("#sortable li").removeClass('ui-state-error').addClass('ui-state-default') 			
		});	
	$(document).ready(
	function()
	{		
		$("button.nascondi").click(function () {		
		$.get("nomenu.php",{"stato":"1"},function(data){		
		if (data == 1) {
      	$("div.nascondi").hide(); 
      	$("button.nascondi").text("Srotola");     	
      }else {
      	$("div.nascondi").show();      	
      	$("button.nascondi").text("Arrotola");
      }});
    });				
	}
	);
	$(document).ready(function() {
  		$('a[title]').cluetip({splitTitle: '|', dropShadow: true,cluetipClass: 'sito',arrows: true, showTitle: false});
	});

	</script>
<?
require_once("auth.php");
require_once("../utility/connessione.php");
$str="SELECT ID, titolo,posizione,attivo,zona,ordine,titvideo FROM moduli order by zona,posizione,ordine";
$risultato=mysql_query($str); 
if (mysql_num_rows($risultato)>0)
{
	$menu = array('t' => array(),'u'=> array(),'a'=> array());
	$menud = array();
	$ord = array('a'=>0,"s"=>1,"c"=>2,"d"=>3,"b"=>4);
	$orda = array('a'=>0,"s"=>1,"c"=>1,"d"=>1,"b"=>2);
	while ($control=mysql_fetch_row($risultato))
	{
		if ($control[3] == "si" )
		{
			if ($control[4]!='a')
				$menu[$control[4]][$ord[$control[2]]][]=$control;
			else
				$menu[$control[4]][$orda[$control[2]]][]=$control;
   	}
   	else
   		$menud[] = $control;
	}
   echo "<div id=\"finestra\" class=\"contenitore\">\n";
   if ($typo !="A")
      {
   		echo "<p>La modifica dell'Area e abilitata solo agli Admin</p>";
   }
   echo "<div class=\"utility\">";
   	if ($typo =="A")
      {
      	echo "<button id=\"cancella\">Cancella</button>
   		<ul id=\"sortable\" class=\"connectedSortable\">Cancella\n</ul>\n<br/>\n";      	
      }
   	
   	echo "<ul id=\"sortable5\" class=\"connectedSortable\">Disattivati\n";
   	for ($i =0; $i < count($menud);$i++)
   	{
   			echo "<li class=\"ui-state-error\" id=\"".$menud[$i][0]."\">";
   			if ($typo =="A")
      		{
      			echo "<a title=\"|Modifica il Modulo\" href=\"area.php?pag=insert_moduli.php&amp;id=".$menud[$i][0]."\">
   				<span class=\"ui-icon ui-icon-pencil\"></span></a>";
   			}
   			echo $menud[$i][1];
   			if ($menu[$i][6] != "") echo "<br/>Titolo:".$menu[$i][6];
   			echo "</li>\n";
   	}
   	echo "</ul>\n
   	</div>\n";
   echo "<div class=\"moduli\"><h3>Moduli Area comune</h3>\n";
   for ($i=0; $i< 5;$i++)
   {
   	echo "<ul id=\"sortable$i\" class=\"connectedSortable\">";
   	switch ($i)
   	{
   		case 0: echo "Moduli Zona Testa";break;
   		case 1: echo "Moduli Zona Sinistra";break;
   		case 2: echo "Moduli Zona Centro";break;
   		case 3: echo "Moduli Zona Destra";break;
   		case 4: echo "Moduli Zona Piede";break;
   	}
   	echo "\n";
   	for($j =0; $j < count($menu['t'][$i]);$j++)
   	{
   			echo "<li class=\"ui-state-default\" id=\"".$menu['t'][$i][$j][0]."\">";
   			if ($typo =="A")
      		{
   				echo "<a title=\"|Modifica il Modulo\" href=\"area.php?pag=insert_moduli.php&amp;id=".$menu['t'][$i][$j][0]."\">
   				<span class=\"ui-icon ui-icon-pencil\"></span></a>";
   			}
   			echo $menu['t'][$i][$j][1];
   			if ($menu['t'][$i][$j][6] != "") echo "<br/>Titolo:".$menu['t'][$i][$j][6];
   			echo "</li>\n";
   	}
   	echo "</ul>\n";
   	if ($i==3)echo "\n<div class=\"azzerafloat\"></div>\n";
   }
   echo "<h3>Moduli Area Utenti(Solo corpo)</h3>\n";
   for ($i=0; $i< 5;$i++)
   {
   	echo "<ul id=\"sortable1$i\" class=\"connectedSortable\">";
   	switch ($i)
   	{
   		case 0: echo "Moduli Zona Testa";break;
   		case 1: echo "Moduli Zona Sinistra";break;
   		case 2: echo "Moduli Zona Centro";break;
   		case 3: echo "Moduli Zona Destra";break;
   		case 4: echo "Moduli Zona Piede";break;
   	}
   	echo "\n";
   	for($j =0; $j < count($menu['u'][$i]);$j++)
   	{
   			echo "<li class=\"ui-state-default\" id=\"".$menu['u'][$i][$j][0]."\">";
   			if ($typo =="A")
      		{
	   			echo "<a title=\"|Modifica il Modulo\" href=\"area.php?pag=insert_moduli.php&amp;id=".$menu['u'][$i][$j][0]."\">
   				<span class=\"ui-icon ui-icon-pencil\"></span></a>";
   			}
   			echo $menu['u'][$i][$j][1];
   			if ($menu['u'][$i][$j][6] != "") echo "<br/>Titolo:".$menu['u'][$i][$j][6];
   			echo "</li>\n";
   	}
   	echo "</ul>\n";
   	if ($i==3)echo "\n<div class=\"azzerafloat\"></div>\n";
   }
   echo "<h3>Moduli Area Admin (non Gestito)</h3>\n";
   for ($i=0; $i< 3;$i++)
   {
   	echo "<ul id=\"sortable2$i\" class=\"connectedSortable\">";
   	switch ($i)
   	{
   		case 0: echo "Moduli Zona Testa";break;
   		case 1: echo "Moduli Zona Centro";break;
   		case 2: echo "Moduli Zona Piede";break;
   	}
   	echo "\n";
   	for($j =0; $j < count($menu['a'][$i]);$j++)
   	{
   			echo "<li class=\"ui-state-default\" id=\"".$menu['a'][$i][$j][0]."\">";
   			if ($typo =="A")
      		{
   				echo "<a title=\"|Modifica il Modulo\" href=\"area.php?pag=insert_moduli.php&amp;id=".$menu['a'][$i][$j][0]."\">
   				<span class=\"ui-icon ui-icon-pencil\"></span></a>";
   			}
   			echo $menu['a'][$i][$j][1];
   			if ($menu['a'][$i][$j][6] != "") echo "<br/>Titolo:".$menu['a'][$i][$j][6];
   			echo "</li>\n";
   	}
   	echo "</ul>\n";   	
   }
   echo "</div>";
   echo "<div class=\"azzerafloat\"></div></div>";
}	
else
{
	echo "<p>Tabella vuota</p>";
}
echo "<br>";

echo "<div class=\"contenitore\"><div class=\"azzerafloat\"></div>
		<div class=\"evidenzia\">
			
				<img src=\"./img/add.png\" id=\"ico\" /> <a href=\"area.php?pag=insert_moduli.php\">Nuovo modulo</a>
			
		</div>
	  </div>";
?>
